package com.guigu.alibaba.controller;


import com.guigu.alibaba.entity.Order;
import com.guigu.alibaba.service.OrderService;
import com.guigu.springcloud.common.CommonResult;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {
    @Resource
    private OrderService orderService;

    // 创建订单
    @GetMapping(value = "/create", produces = "application/json; charset=utf-8")
    @GlobalTransactional(name = "lee-create-order", rollbackFor = Exception.class)
    public CommonResult createOrder(Order order) {
        orderService.create(order);
        return CommonResult.voData(200, "订单创建成功", null);
    }

}
